<!--
 * @Description: 
 * @version: 
 * @Author: 尹鹏孝
 * @Date: 2022-03-07 14:17:52
 * @LastEditors: 尹鹏孝
 * @LastEditTime: 2022-03-07 14:28:06
-->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>移除元素</title>
</head>
<body>
    <script>
        var removeElement = (num, val) => {
                let k = 0;
                for (let i = 0; i < num.length; i++) {
                    if (num[i] != val) {
                        num[k++] = num[i]
                    }
                }
                return num;
            };
           console.log(removeElement([1, 2, 3, 4, 5, 6, 7, 9, 1, 2, 3, 4, 5, 6, 7], 3)) ;
    </script>
</body>
</html>
